<%inherit file="base.html"/>
<h2>
    ${_('Manage content')}
</h2>

<div id="mainPanel">
    <div class="section" id="mycontent">
        <h3>
            ${_('Content')}
            <span class="inlineNav">
                <a href="http://${hexlabel}.hexlabel.net/group/">^ ${_('Back')}</a>
            </span>
        </h3>
        % if errors:
            <div class="alert">${message}</div>
        % elif message:
            <div class="message">${message}</div>
        % endif
        % if content_list['index']:
            <div class="intro">
                <p>${_('Below is all the content that is linked from this group.')}</p>
            
            </div>
            % for mode in ['full', 'empty']:
                % for appiid, index in content_list['app_index'].items():
                    % if (mode == 'full' and len(index) > 0) or (mode == 'empty' and len(index) == 0):
                        <table class="contentTable">
                            <tr>
                                <th>
                                    <h4>
                                        % if content_list['app_meta'][appiid]['iid'] and content_list['app_meta'][appiid]['name']:
                                            <a class="app" href="http://${content_list['app_meta'][appiid]['iid']}.hexlabel.net/">${content_list['app_meta'][appiid]['name']}</a>
                                        % else:
                                            ${_('Unknown Application')}
                                        % endif

                                        % if content_list['app_meta'][appiid]['iid'] and content_list['app_meta'][appiid]['author_profile']:
                                            <span class="author">(${_('version')} ${content_list['app_meta'][appiid]['version']}, ${_('created by')}
                                            <a href="http://${content_list['app_meta'][appiid]['author_profile']['iid']}.hexlabel.net/">${content_list['app_meta'][appiid]['author_profile']['generic']['name']['values'][0]['value']}</a>)</span>
                                        % else:
                                            <span class="author">(${_('Unknown author')})</span>
                                        % endif
                                    </h4>
                                    % if content_list['app_meta'][appiid]['update']:
                                    <div class="update">
                                        <form method="post" action="http://admin.hexlabel.net/group_content/#mycontent" class="listForm contentManageForm">
                                            <input type="hidden" name="appiid" value="${appiid}"/>
                                            <input type="hidden" name="liid" value="${iid}"/>
                                            <p>Application update available for one or more items</p>
                                            <input type="submit" class="submit" name="update_group_content" value="${_('Update all')}"/>
                                        </form>
                                    </div>
                                    % endif
                                </th>
                            </tr>
                            % if mode == 'empty':
                                <tr><td>${_('No content.<br/>Click through to the application profile to see examples and create content with this application.') |n}</td></tr>
                            % endif
                            % for ciid in index:
                            <tr>
                                <td>
                                    <form method="post" action="http://admin.hexlabel.net/group_content/#mycontent" class="listForm contentManageForm">
                                        <p>
                                            <input type="hidden" name="ciid" value="${ciid}"/>
                                            <input type="hidden" name="liid" value="${content_list['items'][ciid]['parent']['iid']}"/>
                                        </p>
                                        <dl>
                                            <dd>
                                                <a href="http://${ciid}.hexlabel.net">
                                                    <img src="${content_list['items'][ciid]['picture']}" class="thumbnail" alt=""/>
                                                </a>
                                                <div class="itemContent">
                                                    <a href="http://${ciid}.hexlabel.net">${content_list['items'][ciid]['title']}</a>
                                                    <div class="version">(${_('version')} ${content_list['items'][ciid]['system']['version']})</div>
                                                    % if content_list['items'][ciid]['parent']['iid'] != my_iid:
                                                        <div class="parentInfo">
                                                            Linked from <a href="http://${content_list['items'][ciid]['parent']['iid']}.hexlabel.net/">${content_list['items'][ciid]['parent']['name']}</a>
                                                        </div>
                                                    % endif
                                                </div>
                                            </dd>
                                            <dd class="buttons">
                                                % if content_list['items'][ciid]['parent']['is_admin']:
                                                    % if not content_list['items'][ciid]['visibility']:
                                                        <div class="roles"><span class="restricted">${_('Friends only')}</span></div>
                                                        <input type="submit" class="submit" name="make_group_content_public" value="${_('Make Public')}"/>
                                                    % else:
                                                        <input type="submit" class="submit" name="make_group_content_private" value="${_('Restrict to Friends')}"/>
                                                    % endif
                                                    <!--
                                                    <input type="submit" class="submit warn" name="update_group_content" value="$_('Update')}"/>
                                                    -->
                                                    <input type="submit" class="submit warn" name="delete_group_content" value="${_('Delete')}"/>
                                                % endif
                                            </dd>
                                        </dl>
                                    </form>
                                    <div class="clr"><br/></div>
                                </td>
                            </tr>
                            % endfor
                        </table>
                    % endif
                % endfor
            % endfor
        % elif content_list['app_meta']:
            <div class="intro">
                <p>${_('Below are the applications that are available at the moment. To view examples of an application, click though to the applciation profile.')}</p>
            
            </div>
            % for appiid in content_list['app_meta']:
                <table id="contentTable">
                    <tr>
                        <th>
                            <h4>
                                % if content_list['app_meta'][appiid]['iid'] and content_list['app_meta'][appiid]['name']:
                                    <a class="app" href="http://${content_list['app_meta'][appiid]['iid']}.hexlabel.net/">${content_list['app_meta'][appiid]['name']}</a>
                                % else:
                                    ${_('Unknown Application')}
                                % endif

                                % if content_list['app_meta'][appiid]['iid'] and content_list['app_meta'][appiid]['author_profile']:
                                    <span class="author">(${_('created by')}
                                    <a href="http://${content_list['app_meta'][appiid]['author_profile']['iid']}.hexlabel.net/">${content_list['app_meta'][appiid]['author_profile']['generic']['name']['values'][0]['value']}</a>)</span>
                                % else:
                                    <span class="author">(${_('Unknown author')})</span>
                                % endif
                            </h4>
                        </th>
                    </tr>
                    <tr><td>${_('No content.<br/>Click through to the application profile to see examples and create content with this application.') |n}</td></tr>
                </table>
            % endfor
        % else:
            <ul>
                <li>${_('No content.')}</li>
            </ul>
        % endif
    </div>
</div>

<!-- defs -->
<%def name="title()">P2P Fusion - Peerscape | ${profile_fields['generic']['name']['values'][0]['value']} | ${_('Manage content')}</%def>
<%def name="body_class()">
    % if is_member:
  	    admin group member
    % else:
  	    admin group
    % endif
</%def>
<%def name="toplinks_style()">
</%def>

